package top.swimmer.tools.data.linked;

public class Length {
    public static int length(ListNode node) {
        if (node == null) {
            return 0;
        }
        int length = 0;
        ListNode current = node;
        while (current != null) {
            length++;
            current = current.next;
        }
        return length;
    }

    public static void main(String[] args) {
        System.out.println(length(ListNode.get()));
    }
}
